package be.kuleuven.cs.mop.domain.model.impl;


import static org.junit.Assert.*;

import org.junit.*;

import be.kuleuven.cs.mop.TestEnvironment;
import be.kuleuven.cs.mop.domain.exceptions.TaskManagerException;



public class InvitationImplTest {
	
	private static TestEnvironment ENV;
	
	
	
	@Before
	public void setUp() {
		ENV = TestEnvironment.newInstance();
	}
	
	
	
	@Test(expected=Exception.class)
	public void testConstructorInvalid0() throws TaskManagerException {
		new InvitationImpl(null, null);
	}
	
	@Test(expected=Exception.class)
	public void testConstructorInvalid1() throws TaskManagerException {
		new InvitationImpl(ENV.task1, null);
	}
	
	@Test
	public void testConstructorValid() throws TaskManagerException {
		final InvitationImpl invitation = new InvitationImpl(ENV.task1, ENV.user1);
		
		assertEquals(invitation.getTask(),		ENV.task1);
		assertEquals(invitation.getUser(),		ENV.user1);
		assertEquals(invitation.getStatus(),	InvitationStatus.PENDING);
		
		assertFalse(invitation.isAccepted());
		assertTrue(invitation.isPending());
		assertFalse(invitation.isRejected());
	}
	
	@Test
	public void testSetStatus() throws TaskManagerException {
		final InvitationImpl invitation = new InvitationImpl(ENV.task1, ENV.user1);
		
		assertFalse(invitation.isAccepted());
		assertTrue(invitation.isPending());
		assertFalse(invitation.isRejected());
		
		invitation.setAccepted();
		assertTrue(invitation.isAccepted());
		assertFalse(invitation.isPending());
		assertFalse(invitation.isRejected());
		
		invitation.setPending();
		assertFalse(invitation.isAccepted());
		assertTrue(invitation.isPending());
		assertFalse(invitation.isRejected());
		
		invitation.setRejected();
		assertFalse(invitation.isAccepted());
		assertFalse(invitation.isPending());
		assertTrue(invitation.isRejected());
	}
	
}